/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * gftp-file.h : 
 *
 * Copyright (C) 2008, 2009 Lingtao Pan
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, 
 * Boston, MA 02111-1307, USA.
 */


#ifndef GFTP_FILE_H
#define GFTP_FILE_H


typedef struct gftp_file gftp_file;

#define GFTP_TRANS_ACTION_OVERWRITE     1
#define GFTP_TRANS_ACTION_RESUME        2
#define GFTP_TRANS_ACTION_SKIP          3

#define GFTP_SORT_COL_FILE          1
#define GFTP_SORT_COL_SIZE          2
#define GFTP_SORT_COL_USER          3
#define GFTP_SORT_COL_GROUP         4
#define GFTP_SORT_COL_DATETIME          5
#define GFTP_SORT_COL_ATTRIBS           6


#define GFTP_IS_SPECIAL_DEVICE(mode)    (S_ISBLK (mode) || S_ISCHR (mode))


struct gftp_file 
{
    char *file,     /* Our filename */
         *user,     /* User that owns it */
         *group,    /* Group that owns it */
         *destfile; /* Full pathname to the destination for the 
                       file transfer */

    int fd;         /* Already open fd for this file */
    

    time_t datetime;      /* File date and time */
    off_t size,           /* Size of the file */
          startsize;      /* Size to start the transfer at */
    mode_t st_mode;       /* File attributes */

    dev_t st_dev;         /* The device and associated inode. These */
    ino_t st_ino;         /* two fields are used for detecting loops
                           * with symbolic links. */

    unsigned int selected : 1,    /* Is this file selected? */
                 was_sel : 1,     /* Was this file selected before  */
                 shown : 1,       /* Is this file shown? */
                 done_view : 1,   /* View the file when done transfering? */
                 done_edit : 1,   /* Edit the file when done transfering? */
                 done_rm : 1,     /* Remove the file when done */
                 transfer_done : 1,     /* Is current file transfer done? */
                 retry_transfer : 1,    /* Is current file transfer done? */
                 exists_other_side : 1, /* The file exists on the other side
                                           during the file transfer */
                 filename_utf8_encoded : 1; /* Is the filename properly UTF8
                                             encoded? */

    char transfer_action;     /* See the GFTP_TRANS_ACTION_* vars above */
    
    void *user_data;   /* the lib user can store his(her) private data here */
};

typedef struct gftp_file_extensions gftp_file_extensions;

struct gftp_file_extensions
{
   char *ext,                   /* The file extension to register */
        *filename,              /* The xpm file to display */
        *view_program,          /* The program used to view this file */
        *ascii_binary;          /* Is this a ASCII transfer or a BINARY transfer */
   unsigned int stlen;          /* How long is the file extension. */
};


gftp_file* gftp_file_copy (gftp_file *fle);
void  free_file_list            (GList *filelist);
void  gftp_file_destroy         (gftp_file *file, int free_it);


#endif
